let latitude = null,
    longitude = null;
if (navigator.geolocation) {
    var timeoutVal = 10 * 1000 * 1000;
    navigator.geolocation.getCurrentPosition(
        displayPosition,
        displayError, {
            enableHighAccuracy: true,
            timeout: timeoutVal,
            maximumAge: 0
        }
    );
} else {
    alert("Geolocation is not supported by this browser");
    //alert("应用不支持定位功能");
}

function displayPosition(position) {
    // alert("Latitude: " + position.coords.latitude + ", Longitude: " + position.coords.longitude);
    latitude = position.coords.latitude;
    longitude = position.coords.longitude;
}

function displayError(error) {
    var errors = {
        1: '申请拒绝',
        2: '无法精确匹配地址',
        3: '请求超时'
    };
    alert("错误: " + errors[error.code]);
}

export default {
    latitude,
    longitude
}